package edu.qust.controller;

import com.alibaba.fastjson.JSONObject;
import edu.qust.domain.Admin;
import edu.qust.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
public class AdminController {
    @Autowired
    private AdminService adminService;


    @GetMapping("/login")
    public String login(){
        return "login";
    }

    @GetMapping("/dologin")
    public @ResponseBody
    JSONObject dologin(Admin adm, HttpSession session){
        JSONObject json=new JSONObject();
        String result=adminService.login(adm,session);
        json.put("result",result);
        return json;
    }
}
